#!/bin/bash

read -p "please input user's name:" u_name
if id ${u_name} &>/dev/null;then
for i in {1..3}
do
	read -p "please input ${u_name} :" u_pwd
	if (( ${#u_pwd} >= 8 ));then
		if echo ${u_pwd} |grep --color "[0-9]" |grep --color "[a-z]" &>/dev/null;then
			echo "$u_pwd" |passwd ${u_name}  --stdin
			exit
		else
			echo "${u_pwd} is not include charactor digit,please again input:"
		fi
	else
		echo "the length of ${u_name} password is lesser that 8 character"
	fi
done
else
	echo "no such ${u_name} user"
fi
